﻿using Serialize.model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Serialize
{
    class Program
    {
        static void Main(string[] args)
        {
            string xmlSerializerPath = "Product.XmlSerialize.xml";
            string binarySerializePath = "Product.binarySerialize.xml";
            string javaScriptSerialize = "Product.javaScriptSerialize.xml";
            string dataContractSerialize = "User.dataContractSerialize.xml";
            Serializer.XmlSerialize<Product>(xmlSerializerPath, new Product("Visual Studio", "软件开发工具"));
            Serializer.BinarySerialize<Role>(binarySerializePath, new Role("admin", "管理员，拥有系统最高权限"));
            Serializer.JavaScriptSerialize<Product>(javaScriptSerialize, new Product("Unity3D", "游戏开发工具"), Encoding.UTF8);
            Serializer.DataContractSerialize<User>(dataContractSerialize, new User("zgm", "zgm"));

            Console.WriteLine("Xml反序列化：\r\n{0}", Serializer.XmlDeserialize<Product>(xmlSerializerPath));
            Console.WriteLine("二进制反序列化：\r\n{0}", Serializer.BinaryDeserialize<Role>(binarySerializePath));
            Console.WriteLine("JavaScript反序列化：\r\n{0}", Serializer.JavaScriptDeserialize<Product>(javaScriptSerialize));
            Console.WriteLine("DataContract反序列化：\r\n{0}", Serializer.DataContractDeserialize<User>(dataContractSerialize));
            Console.ReadKey(true);
        }
    }
}
